<template>
    <view>
        <!-- components/goods/index.wxml -->
        <!-- 列表 -->
        <view class="list">
            <!-- 左边 -->
            <view class="list-info" v-for="(item, index) in dataList" :key="index">
                <view class="list-info-detail" @tap="onDetail($event, { id: item.id })" :data-id="item.id">
                    <view class="list-info-detail-title">{{ item.title }}</view>
                    <view class="list-info-detail-div" v-if="item.photo_img">
                        <view class="desc">
                            <view class="desc-text">{{ item.desc }}</view>
                        </view>
                        <view class="photo">
                            <view class="photo-img">
                                <image :src="item.photo_img + '?x-oss-process=image/resize,w_320'" mode="widthFix" :data-index="index"></image>
                            </view>
                        </view>
                    </view>
                    <view class="list-info-detail-div" v-else>
                        <view class="desc-text">{{ item.desc }}</view>
                    </view>
                </view>
            </view>
        </view>
        <view class="list-end" v-if="isEnd == 'end'">已经到底啦</view>
    </view>
</template>

<script>
// components/goods/index.js
const Config = require('../../config/index.js');

export default {
    data() {
        return {
            imgUrl: Config.imgUrl //图片url
        };
    },
    /**
     * 组件的属性列表
     */
    props: {
        dataList: {
            // 商品数据
            type: Array,
            default: () => []
        },
        //数据是否加载完成
        isEnd: {
            type: String,
            default: 'start'
        }
    },
    /**
     * 组件的方法列表
     */
    methods: {
        //专栏详情
        onDetail(e, _dataset) {
            
            if (!e.currentTarget) {
                if (_dataSet.tagId) {
                    e.currentTarget = {
                        id: _dataSet.tagId
                    };
                } else {
                    e.currentTarget = {
                        dataset: _dataSet
                    };
                }
            }
            
            let id = e.currentTarget.dataset.id;
            uni.navigateTo({
                url: '/pages/information/detail/index?id=' + id
            });
        }
    }
};
</script>
<style>
@import './index.css';
</style>
